Repository navigation
Retry a throttled DeleteSecret in the Secrets Manager integration tests - #162
Draft
AlexDaines wants to merge 1 commit into
Draft
AlexDaines wants to merge 1 commit into
AlexDaines wants to merge 1 commit into
Conversation
Secrets Manager sometimes answers DeleteSecret with HTTP 400 ThrottlingException. The released client does not retry it and raises a plain CallError, which failed 9 of 122 pull request builds since 19 November. delete_secret_with_retry retries an unmodeled HTTP 400 on the delete each second for up to 5 seconds. All three DeleteSecret calls of these tests use it. Remove it when the pins move to a smithy-python release with smithy-lang/smithy-python#955.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Secrets Manager sometimes throttles a
DeleteSecretthat comes soon after a write to the secret. CloudTrail records the answer asThrottlingException, "Request throttled due to resource contention", and the client sees HTTP 400. The released client treats only HTTP 429 as a throttle, so it does not retry this answer. It raises a plainCallErrorwith no error code:Since these tests entered
developon 19 November, 9 of 122 pull request builds failed on this error, 2 of them also in the teardown of thesecret_namefixture. smithy-lang/smithy-python#955 makes the client retry it, but it is in no release yet.Fix
delete_secret_with_retryruns the delete throughwait_until, like the S3 helperuntil_visible: an unmodeled HTTP 400 becomes a sentinel, andwait_untilretries it each second for up to 5 seconds. All threeDeleteSecretcalls of these tests use it.The error carries no error code, so another unmodeled HTTP 400 (an access-denied answer, for example) is retried too. If it clears within 5 seconds, the test passes. If it stays, the test fails 5 seconds late, with the
CallErrorin the cause chain. Modeled errors are not retried.response_metadatais always set on aCallError, so the status check is safe.The helper has a TODO to remove it when the smithy pins in
pyproject.tomlmove to a release with #955.Testing
Ran these tests against a fake Secrets Manager with the released packages, in async and sync modes. A throttle on the first one or two attempts passes after the retries. A throttle on each attempt fails after 5 seconds with
TimeoutError, and the log shows theCallError.ResourceNotFoundExceptionfails at once. Without this change, the fake fails the same tests with the error above.ruffandpyrightpass.I did not run the tests against the live service. The pull request build does that, but the error shows in about 1 build in 14, so one green build does not prove the retry. The 5 seconds are a first value: no build shows how long the throttle lasts, because the client made one attempt each time.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.